# -*- coding: utf-8 -*-
# @Time    : 2021/4/29 17:25
# @Author  : lilu
# @Email   : 1906196327@qq.com
# @File    : 作业.py
# @Software: PyCharm

import string
import  random
with open("big.txt","w+",encoding="utf-8") as f:
    for i in range(1000):
        # f.write('aaaaaaaaaaaaaaa\n')
        f.write(("".join(random.choices(string.ascii_lowercase,k=random.randint(1,50)))+"\n"))


def read_file(path):
    SIZE = 50000
    with open(path,"rb") as f:
        while True:
            block = f.read(SIZE)
            if block:
                yield block
            else:
                return

g = read_file("big.txt")
j = [0]
for i in g:
     if len(i) >= j[0]:
         j.remove(j[0])
         j.append(len(i))
     else:
         continue
print(f"字符长度最长的长度为:{j[0]}")

